<template>
	<view>
		<view style="height: 100px;" class="">
			<view class="search" @click="search">
				搜索文字
			</view>
			<view class="top">
				<view class="top_left">
					<view style="display: flex;align-items: center;" @click="map">
						<image src="../../static/收藏.png" mode=""></image>
						<text style="margin: 0 5px;">{{site}}</text>
						<image src="../../static/向右箭头.png" mode=""></image>
					</view>
					<view style="font-size: 13px;color: #AAAAAA;margin-top: 3px;">
						距离您15.4km
					</view>
				</view>
				<view class="top_right">
					<view style="background-color: #000000;color: #FFFFFF;	border-radius: 20px 0 0 20px;">
						自取
					</view>
					<view style="background-color: #DCDCDC;color: gray;	border-radius: 0 20px 20px 0;">
						外卖
					</view>
				</view>
			</view>
		</view>
		<view class="cont">
			<view class="cont_left">
				<view v-for="(item,index) in title" :key="index" class="con" :class="Index === index?'active':''"
					@click="click(index)">
					<view>
						<image :src="item.img" mode="" style="width: 24px;height: 24px;"></image>
					</view>
					<view>
						{{item.name}}
					</view>
				</view>
			</view>
			<view class="cont_right" @touchmove="touchMove">
				<view class="bigImg">
					<view class="uni-padding-wrap">
						<view class="page-section swiper">
							<view class="page-section-spacing">
								<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay"
									:interval="interval" :duration="duration">
									<swiper-item>
										<image src="../../static/1.png" mode=""></image>
									</swiper-item>
									<swiper-item>
										<image src="../../static/1.png" mode=""></image>
									</swiper-item>
									<swiper-item>
										<image src="../../static/1.png" mode=""></image>
									</swiper-item>
								</swiper>
							</view>
						</view>
					</view>
				</view>
				<view class="bigImg">
					<view class="uni-padding-wrap">
						<view class="page-section swiper">
							<view class="page-section-spacing">
								<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay"
									:interval="interval" :duration="duration">
									<swiper-item>
										<image src="../../static/2.png" mode=""></image>
									</swiper-item>
									<swiper-item>
										<image src="../../static/2.png" mode=""></image>
									</swiper-item>
									<swiper-item>
										<image src="../../static/2.png" mode=""></image>
									</swiper-item>
								</swiper>
							</view>
						</view>
					</view>
				</view>
				<view v-for="(item,id) in title" :key="index">
					<view class="grop"
						style="margin-left: 5px;margin-top: 10px;margin-bottom: 10px;font-size: 14px;color: #7F7F7F;">
						{{item.name}}
					</view>
					<view class="con" @click="Tan(item)" v-for="(item,index) in navList" :key="index"
						v-if="Number(item.state) === id + 1">
						<view style="margin-right: 10px;">
							<image :src="item.img" mode=""></image>
						</view>
						<view style="position: relative;">
							<view style="margin-bottom: 5px;">{{item.name}}</view>
							<view style="font-size: 12px;display: flex;margin-bottom: 5px;" class="hint">
								<view v-for="(items,index) in JSON.parse(item.hint)" :key="index"
									style="display: flex;">
									{{items}}
								</view>
							</view>
							<view style="font-size: 13px;color: #7F7F7F;margin-bottom: 5px;">{{item.introduc}}
							</view>
							<view>￥{{item.price}}</view>
							<view style="width: 16px;height: 16px;background-color: #DBA871;border-radius: 100%;
								text-align: center;line-height: 15px;position: absolute;color: white;
								right: 10px;bottom: 0;">+</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="bottom" v-if="shopList.length > 0">
			<view class="" style="margin-left: 90px;">
				￥{{Zprice}}
			</view>
			<view class="btn">结算</view>
			<view class="car" @click="shopCar">
				<image src="../../static/购物袋(1).png" mode=""></image>
				<view style="position: absolute;right: -5px;top: 0;width: 18px;
				height: 18px;color: white;border-radius: 100%;background-color: #DBA871;
				text-align: center;line-height: 18px;">{{shopList.length}}</view>
			</view>
		</view>
		<Alert v-if="flag" :flag="flag" @close="close" @Data="Data" />
		<shopCar v-if="carFlag" :carFlag="carFlag" @carClose="carClose" :shopList="shopList" @price="price" />
	</view>
</template>

<script>
	import Alert from './alert.vue'
	import shopCar from './shopCar.vue'
	export default {
		components: {
			Alert,
			shopCar
		},
		data() {
			return {
				title: [{
						img: '../../static/实验瓶.png',
						name: '喜茶实验室'
					},
					{
						img: '../../static/花 喇叭花 鲜花.png',
						name: '当即限定'
					},
					{
						img: '../../static/饮料(1).png',
						name: '人气必喝榜'
					},
					{
						img: '../../static/冰淇淋.png',
						name: '喜茶制冰'
					}
				],
				Index: 0,
				navList: [],
				shopList: [],
				carList: [],
				background: ['color1', 'color2', 'color3'],
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				ScrollTop: '',
				flag: false,
				site: '美年广场GO店',
				carFlag: false,
				Zprice: ''
			}
		},
		mounted() {
			this.getNavList()
			this.getShopData()
			setTimeout(() => {
				this.shopList = this.$store.state.ordermeal.Shop
			}, 200)
			setTimeout(() => {
				this.Zprice = this.$store.getters['ordermeal/ZJ']
			}, 200)
		},
		computed: {

		},
		onPageScroll(e) {
			console.log(e.scrollTop)
		},
		onLoad(option) {
			this.flag = option.flag
		},
		methods: {
			getNavList() {
				this.$store.dispatch('ordermeal/getNavList').then(res => {
					this.navList = res
				})
			},
			getShopData() {
				this.$store.dispatch('ordermeal/getShopData')
			},
			click(index) {
				this.Index = index
			},
			touchMove() {
				let obj = uni.createSelectorQuery().select('.grop')
				obj.boundingClientRect((res) => {
					// console.log(res)

				}).exec()

			},
			Tan(item) {
				this.flag = true
				this.$store.commit('ordermeal/Xqitem', item)
			},
			close(flag) {
				this.flag = flag
			},
			map() {
				uni.chooseLocation({
					success: (res) => {
						console.log(res)
						this.site = res.name
					}
				})
			},
			Data(data, price) {
				this.shopList = data
				this.Zprice = price
			},
			shopCar() {
				this.carFlag = true
			},
			carClose(flag) {
				this.carFlag = flag
			},
			price(price) {
				this.Zprice = price
			},
			search(){
				uni.navigateTo({
					url: '../../components/searchPage/index',
				});
			}
		}
	}
</script>
<style>
	page {
		background-color: #FFFFFF;
	}
</style>
<style scoped>
	* {
		padding: 0;
		margin: 0;
		list-style: none;
	}

	.search {
		margin-top: 24px;
		width: 240px;
		height: 32px;
		background-color: #F2F2F2;
		border-radius: 20px;
		display: flex;
		align-items: center;
		padding-left: 20px;
		color: gray;
		margin-left: 10px;
	}

	.top {
		margin-top: 20px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 10px;
	}

	.top_left image {
		width: 16px;
		height: 16px;
	}

	.top_right {
		display: flex;
		font-size: 14px;
	}

	.top_right view {
		width: 50px;
		height: 30px;
		text-align: center;
		line-height: 30px;
	}

	.cont_left {
		width: 80px;
		height: calc(100vh - 125px);
		float: left;
		overflow-y: auto;
		background-color: #F6F6F6;
		font-size: 14px;
	}

	.cont_left .con {
		height: 62px;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		color: #AAAAAA;
	}

	.cont_right {
		width: calc(100% - 80px);
		height: calc(100vh - 125px);
		float: left;
		overflow-y: auto;
	}

	.cont_right .bigImg {
		width: 279px;
		height: 155px;
		margin-left: 10px;
		margin-bottom: 10px;
	}

	.cont_right .bigImg image {
		width: 279px;
		height: 155px;
	}

	.cont_left .active {
		background-color: white;
		color: black;
	}

	.cont_right .con {
		display: flex;
		width: 283px;
		height: 108px;
		margin-left: 5px;
		align-items: center;
		margin-bottom: 20px;
	}

	.cont_right .con image {
		width: 60px;
		height: 60px;
	}

	.hint view:nth-child(1) {
		width: 32px;
		height: 18px;
		background-color: #EEFFE8;
		color: #70B309;
		margin-right: 10px;
		display: flex;
		justify-content: center;
	}

	.hint view:nth-child(2) {
		width: 53px;
		height: 18px;
		background-color: #E9E9E9;
		color: #A9A9A9;
		margin-right: 10px;
		display: flex;
		justify-content: center;
	}

	.bottom {
		width: 100%;
		height: 50px;
		position: fixed;
		bottom: 0;
		background-color: white;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.bottom .btn {
		width: 100px;
		height: 50px;
		background-color: #DBA871;
		color: white;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.car {
		position: absolute;
		width: 50px;
		height: 50px;
		background-color: white;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 100%;
		bottom: 5px;
		left: 15px;
		box-shadow: 1px 1px 10px 0px #999999;
	}

	.car image {
		width: 24px;
		height: 24px;
	}
</style>
